Avoid integer overflow
authorMatthias Clasen <mclasen@redhat.com>
Sun, 30 Jun 2013 02:06:54 +0000 (22:06 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 30 Jun 2013 02:06:54 +0000 (22:06 -0400)
Use g_malloc_n in gdk_cairo_set_source_pixbuf when allocating
a large block of memory, to avoid integer overflow.

Pointed out by Bert Massop in
https://bugzilla.gnome.org/show_bug.cgi?id=703220

gdk/gdkcairo.c

index 19bed047dba3cfb23bdb1da1e103c487df87aa14..2e1d8dc3f836ff7c981e19cc992fbf915d053b2c 100644 (file)
@@ -213,7 +213,7 @@ gdk_cairo_set_source_pixbuf (cairo_t         *cr,
     format = CAIRO_FORMAT_ARGB32;
 
   cairo_stride = cairo_format_stride_for_width (format, width);
-  cairo_pixels = g_malloc (height * cairo_stride);
+  cairo_pixels = g_malloc_n (height, cairo_stride);
   surface = cairo_image_surface_create_for_data ((unsigned char *)cairo_pixels,
                                                  format,
                                                  width, height, cairo_stride);